<template>
  <div class="base-echarts">
    <div ref="echartDivRef" :style="{ width: width, height: height }"></div>
    <!-- <div ref="echartDivRef" :style="{ width: '360px', height: '270px' }"></div> -->
  </div>
</template>

<script setup>
import { onMounted, ref, watchEffect } from "vue";
import useEchart from "./useEchart";

const props = defineProps({
  options: Object,
  width: {
    type: String,
    default: () => "100%",
  },
  height: {
    type: String,
    default: () => "280px",
  },
});

const echartDivRef = ref();

onMounted(() => {
  const { setOptions, updateSize } = useEchart(echartDivRef.value);

  watchEffect(() => {
    // updateSize();
    setOptions(props.options);
  });
});
</script>

<style lang="less" scoped>
.base-echarts {
  width: 100%;
  height: 100%;
}
</style>